// API配置文件
// 集中管理所有API路径，方便后期更换后端API地址

/**
 * API路径配置
 * 所有API路径都相对于baseURL，集中在此处定义
 */
const apiPaths = {
  // 认证相关
  auth: {
    wxLogin: '/user/wx-login',
    refreshToken: '/user/refresh-token',
    logout: '/user/logout',
    // 备用登录路径
    wxLoginAlternatives: [
      '/user/wechat-login',
      '/api/user/wx-login',
      '/api/user/wechat-login',
      '/auth/wechat',
      '/auth/wxlogin'
    ]
  },
  
  // 用户相关
  user: {
    profile: '/user/profile',
    profileById: (userId) => `/user/profile/${userId}`,
    avatar: '/user/avatar',
    studentProfile: '/user/student-profile',
    education: '/user/education',
    experience: '/user/experience',
    experienceById: (id) => `/user/experience/${id}`,
  },
  
  // 存储相关
  storage: {
    upload: '/storage/upload',
    getFile: (objectId) => `/storage/file/${objectId}`,
    objectUrl: '/storage/object-url',
    signedUrl: '/storage/signed-url'
  },
  
  // 职业规划相关
  careerPlan: {
    get: '/student/career-plan',
    create: '/student/career-plan',
    update: '/student/career-plan',
  },
  
  // 性格测试相关
  personality: {
    get: '/student/personality',
    create: '/student/personality',
    update: '/student/personality',
  },
  
  // 兴趣爱好相关
  hobby: {
    get: '/api/student/hobbies',
    update: '/api/student/hobbies'
  },
  
  // MBTI相关API路径
  mbti: {
    userId: '/mbti/userid',
    version: '/mbti/version',
    result: '/mbti/result',
    wxLoginAlternatives: [] // 备用路径，如果需要的话
  }
};

/**
 * API配置对象
 */
const config = {
  // 默认基础URL，可以通过updateBaseURL方法更新
  baseURL: 'https://ubvavqrfetop.sealosbja.site/v1',
  
  /**
   * 获取完整的API URL
   * @param {string} path - API路径
   * @returns {string} - 完整URL
   */
  getFullUrl: function(path) {
    return `${this.baseURL}${path}`;
  }
};

// 将API路径添加到配置对象
config.paths = apiPaths;

module.exports = config; 